package com.tanhua.model.vo;


import com.tanhua.model.pojo.TestOption;
import com.tanhua.model.pojo.TestQuestion;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class TestQuestionVo implements Serializable {
    private String id;          //题目id
    private String question;    //题目内容
    private List<TestOptionVo> options;    //选项集合


    public static TestQuestionVo init(TestQuestion testQuestion,List<TestOption> options){
        TestQuestionVo vo = new TestQuestionVo();
        vo.setId(testQuestion.getId().toString());
        vo.setQuestion(testQuestion.getTxt());

        List<TestOptionVo> optionVos = new ArrayList<>();
        for (TestOption option : options) {
            TestOptionVo Ovo = TestOptionVo.init(option);
            optionVos.add(Ovo);
        }
        vo.setOptions(optionVos);
        return vo;
    }
}
